package com.asiainfo.work.controller;

import com.asiainfo.work.request.zentao.BugRequest;
import com.asiainfo.work.service.second.ZtBugService;
import com.asiainfo.work.utils.BaseController;
import com.asiainfo.work.utils.BaseResponse;
import com.asiainfo.work.utils.PageResponse;
import com.asiainfo.work.vo.BugClosedConsumeTimeStatistics;
import com.asiainfo.work.vo.BugClosedStatistics;
import com.asiainfo.work.vo.BugConsumeTimeStatistics;
import com.asiainfo.work.vo.BugStatistics;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * controller
 * </p>
 *
 * @author baifan
 * @date 2021-01-06
 */
@CrossOrigin
@RestController
@RequestMapping("/zt/bug")
@Validated
@Slf4j
@Api(value = "ZtBugController", tags = {"禅道bug管理"})
public class ZtBugController extends BaseController {

    @Resource
    private ZtBugService ztBugService;

    /**
     * 解决禅道bug消耗总时间
     * @param bugRequest 查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryConsumeBugTime")
    @ApiOperation(value = "解决禅道bug消耗总时间", notes = "解决禅道bug消耗总时间", httpMethod = "POST")
    public BaseResponse<PageResponse<BugConsumeTimeStatistics>> queryConsumeBugTime(@RequestBody BugRequest bugRequest){
        return ztBugService.queryConsumeBugTime(bugRequest);
    }

    /**
     * 已经关闭的bug消耗时间
     * @param bugRequest 查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryClosedBugConsumeTime")
    @ApiOperation(value = "已经关闭的bug消耗总时间", notes = "解决禅道bug消耗总时间", httpMethod = "POST")
    public BaseResponse<PageResponse<BugClosedConsumeTimeStatistics>> queryClosedBugConsumeTime(@RequestBody BugRequest bugRequest){
        return ztBugService.queryClosedBugConsumeTime(bugRequest);
    }

    /**
     * 统计总bug数
     * @param bugRequest 查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryBugCount")
    @ApiOperation(value = "统计总bug数", notes = "统计总bug数", httpMethod = "POST")
    public BaseResponse<PageResponse<BugStatistics>> queryBugCount(@RequestBody BugRequest bugRequest){
        return ztBugService.queryBugCount(bugRequest);
    }

    /**
     * 统计已经关闭的bug数
     * @param bugRequest 查询条件
     * @return 分页返回任务数
     */
    @PostMapping("queryBugClosedCount")
    @ApiOperation(value = "统计已经关闭的bug数", notes = "统计已经关闭的bug数", httpMethod = "POST")
    public BaseResponse<PageResponse<BugClosedStatistics>> queryBugClosedCount(@RequestBody BugRequest bugRequest){
        return ztBugService.queryBugClosedCount(bugRequest);
    }

}
